package guijavacommander.actions;

import guijavacommander.FilePanel;
import guijavacommander.tasks.Task;
import guijavacommander.JavaCommander;
import guijavacommander.tasks.RemoveFilesTask;
import guijavacommander.tasks.ThreadStatusDialog;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.io.File;

/**
 * User: Deady
 * Date: 16.07.2009
 * Time: 12:33:35
 */
public class RemoveFilesAction extends AbstractAction {
    public void actionPerformed(ActionEvent e) {
        JavaCommander cmd = JavaCommander.instance;
        FilePanel active = cmd.getActivePanel();

        File[] selected = active.getSelectedFiles();

        if (JOptionPane.showConfirmDialog(cmd, "Remove "+selected.length+" files?",
                "Attention", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
            Task task = new RemoveFilesTask(selected);
            new ThreadStatusDialog(cmd, task).execute();
            active.deselectAll();
            active.refresh();
        }


    }

}
